/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cw.view;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;

/**
 *
 * @author SVN - Team
 */
public class Loading extends GameCanvas implements Runnable {

    private int per = 0;
    private MReviewer curDisplay;
    private FromListEstablishments frmListEst;

    public Loading(MReviewer curDisplay) {
        super(true);
        this.curDisplay = curDisplay;
        Thread t = new Thread(this);
        t.start();
    }

    private void draw(Graphics g) {
        // g.drawString(per + "%", 50, 195, Graphics.VCENTER | Graphics.HCENTER);
        g.setColor(0xffffff);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.setColor(0, 0, 255);
        g.drawString("Welcome to application", 23, 10, g.LEFT | g.TOP);
        g.setColor(0x0000ff);
        g.drawString(per + "%", this.getWidth() / 2 - 5, 185, g.TOP | g.LEFT);
        g.setColor(255, 0, 200);
        //g.drawString(per + "%", 50, 195, Graphics.VCENTER | Graphics.HCENTER);
        g.fillRect(20, 200, 200, 4);
        g.setColor(0, 0, 255);
        g.fillRect(20, 201, (0 + per) * 2, 2);
        flushGraphics();
        System.out.println("Drawing...");
    }

    public void run() {
        while (true) {
            Graphics g = getGraphics();
            draw(g);
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
            if (per >= 100) {
                break;
            }
            per++;
        }/**/
        //frmListEst = new FromListEstablishments(curDisplay);
        //Display.getDisplay(curDisplay).setCurrent(frmListEst);
    }
}
